<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%String path = request.getContextPath();

			%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic"%>
<html:html locale="true">
<head>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">
	<title></title>
	<link href="console.css" rel="stylesheet" type="text/css">
	<style type="text/css">
<!--
.style1 {font-size: 16px}
-->
.even {
	background:	#eee;
}

.odd {

}
</style>
</head>

<body>
	<jsp:include page="/title.jsp" flush="true" />

	<p class="lnkhead2">
		<bean:write name="title" />
	</p>

	<form action="type.do?" method="post" name="form">
		<table width="100%" border="0" cellpadding="1" class="sort-table" id="table-1" cellspacing="0">

			<thead>
				<tr>
					<td align="center" width="5%">
						&nbsp;

					</td>
					<td align="center" width="15%">

						<bean:message key='typeInfo.id' />

					</td>
					<td align="center" width="25%">

						<bean:message key='typeInfo.name' />

					</td>


					<td align="center" width="20%">

						<bean:message key='typeInfo.parentId' />

					</td>




				</tr>
			</thead>
			<tbody>
				<%int i = 0;
			String color;
			String check = "";%>

				<logic:iterate id="group" name="typelist">

					<%i++;
			if (i % 2 == 1)
				color = "odd";
			else
				color = "even";
			if (i == 1)
				check = "checked";
			else
				check = "";%>

					<tr class="<%=color%>">
						<td align="center">
							<input type="radio" <%=check%> name="typeIndex" value="<bean:write name='group' property='type'/>"
								onclick="javascript:onSelected(
		'<bean:write name='group' property='type'/>',
		'<bean:write name='group' property='name'/>',
		'<bean:write name='group' property='parent'/>'
		)" />
						</td>
						<td align="left">
							<bean:write name="group" property="type" filter="true" />
						</td>
						<td align="left">
							<bean:write name="group" property="name" filter="true" />
						</td>



						<td align="center">

							<bean:write name="group" property="parent" filter="true" />

						</td>





					</tr>

				</logic:iterate>


			</tbody>
		</table>

		<input type="button" name="Submit3" value='<bean:message key='button.delete'/>' onclick="javascript:deleteGroup()">
		<input type="button" name="Submit3" value='<bean:message key='button.update'/>' onclick="javascript:update1()">
		<input type="button" name="Submit3" value='<bean:message key='button.add'/>' onclick="javascript:add1()">
		&nbsp;&nbsp;
		<input type="button" name="Submit4" value='<bean:message key='button.moveup'/>' onclick="javascript:up()">
		<input type="button" name="Submit5" value='<bean:message key='button.movedown'/>' onclick="javascript:down()">
		<div id="addgroup_form" style="visibility:hidden; z-index:2">

			<table width="100%" border="0" cellpadding="0" cellspacing="0">
				<input type="hidden" name="act" />
				<input type="hidden" name="updateType" />
				<input type="hidden" name="domain" value="<bean:write name='domain'/>" />
				<input type="hidden" name="typeType" value="<bean:write name='typeType'/>" />
				<input type="hidden" name="title" value="<bean:write name='title'  filter="true" />" />
				<tr class="txtnormal2">

					<td>
						<bean:message key='typeInfo.id' />
						:

						<input type="text" name="type" size="16" />

					</td>
					<td>
						<bean:message key='typeInfo.name' />
						:

						<input type="text" name="name" size="16" />

					</td>

					<td>
						<bean:message key='typeInfo.parentId' />
						:
						<html:select name="ObjectType" property="parent">
							<option value="">
								<bean:message key='none' />
							</option>
							<logic:notEmpty name="typelist">
								<html:options collection="typelist" property="type" labelProperty="name"></html:options>
							</logic:notEmpty>
						</html:select>
					</td>
					<td>
					</td>

					<td>
						<input type="button" name="add_button" value='<bean:message key="action.add"/>' onclick="javascript:addGroup()">
					</td>
				</tr>
				
			</table>
		</div>
		</form>

		<script language="JavaScript">		
var st = new SortableTable(document.getElementById("table-1"),
	["None", "String","String",  "String"]);
</script>
		<script language="JavaScript">	
function onSelected(type,name,parent){
var frm = document.forms["form"];
frm.elements["type"].value = type;
frm.elements["name"].value = name;
frm.elements["parent"].value = parent;
}
	function addGroup()
	{
		var frm = document.forms["form"];
		if(frm.elements["act"].value =="add"){
		if(!checkId(frm.elements["type"],"<bean:message key='typeInfo.id'/>")){
		return;
		}
		}else{
		var id=(selectedRadiobox(frm,"typeIndex"));
	if(id==null) return;
	frm.elements["updateType"].value=id;
	}
	if(frm.elements["name"].value=="")
	{ alert("<bean:message key='typeInfo.nameCanNotNull'/>");
		return;
	}
	if(frm.elements["parent"].value==frm.elements["type"].value)
	{ alert("<bean:message key='typeInfo.parentCanNotBeSelf'/>");
		return;
	}
	frm.submit();
	
	};
	

	function deleteGroup()
	{
	var frm = document.forms["form"];
	var id=(selectedRadiobox(frm,"typeIndex"));
	if(id==null) return;
	if( !confirm("<bean:message key='button.confirmDelete'/>ID:"+id)) return;
	frm.elements["act"].value="delete";
	frm.elements["type"].value=id;
	frm.submit();
	};
	
	function update1()
	{
	var frm = document.forms["form"];
	var id=(selectedRadiobox(frm,"typeIndex"));
	if(id==null) return;
	frm.elements["type"].value = id;
	frm.elements["type"].disabled = true;
	frm.elements["add_button"].value = "<bean:message key='button.update'/>";
	frm.elements["act"].value = "update";
	shift_visibility(addgroup_form);
	};
	function up()
	{
	var frm = document.forms["form"];
	var id=(selectedRadiobox(frm,"typeIndex"));
	if(id==null) return;
	frm.elements["type"].value = id;
	frm.elements["act"].value = "up";
	frm.submit();
	};
	
	function down()
	{
	var frm = document.forms["form"];
	var id=(selectedRadiobox(frm,"typeIndex"));
	if(id==null) return;
	frm.elements["type"].value = id;
	frm.elements["act"].value = "down";
	frm.submit();
	};

function add1()
	{
	var frm = document.forms["form"];
	
	frm.elements["type"].disabled = false;
	frm.elements["add_button"].value = "<bean:message key='button.add'/>";
	frm.elements["act"].value = "add";
	shift_visibility(addgroup_form);
	};

	function shift_visibility(image1){
 if(image1.style.visibility == "visible")
  image1.style.visibility = "visible";
  else  image1.style.visibility = "visible";
}

</script>
		<%@ include file="/table_bottom.jsp"%>
		<logic:notEmpty name="returnMsg">
			<script>
	parent.frames[0].location.reload();
	alert('<bean:write name="returnMsg"/>');
	</script>
		</logic:notEmpty>
</body>
</html:html>
